import request from './request.js'
import siteinfo from '@/siteinfo.js'
//

export const register = (params) => request('/auth/registerByPhone',params)
export const getcode = (params) => request('/auth/registerPhoneCode',params)
export const login = (params) => request('/auth/thirdAuthLogin',params)
export const getMainClass = () => request('/core/mainPage/goldServices',{},'get')
export const services = () => request('/core/mainPage/services',{},'get')
export const getUser = (params) => request('/system/user/getInfo',params,'get')
export const recommend = (params) => request('/core/custom/hp/list',params)
export const searchswiper = () => request('/core/mainPage/bestItem',{},'get')
export const gwcnums = () => request('/core/userCart/totalItemNum')
export const orderNoticeNum = () => request('/core/userOrder/orderNoticeNum',{},'get')
export const classDetail = (params) => request('/core/cat/services',params,'get')
export const classList = (params) => request('/core/cat/list',params,'get')
export const cancalOrder = (params) => request('/core/userOrder/cancelOrder',params)
export const confirmOrder = (params) => request('/core/userOrder/confirmOrder',params)
export const closeOrder = (params) => request('/core/userOrder/closeOrder',params)
export const ticketList = (params) => request('/core/userOrder/ticketList',params,'get')
export const getOrderList = (params) => request('/core/userOrder/list',params,'get')
export const balance = (params) => request('/core/userOwner/account/list',params,'get')
export const orderpingjia = (params) => request('/core/userOrder/reviews',params)
export const addShopCar = (params) => request('/core/userCart/add',params)
export const ShopCar = (params) => request('/core/userCart/list',params,'get')
export const gwcaradd = (params) => request('/core/userCart/addNum',params)
export const ShopCarDelete = (params) => request('/core/userCart/remove',params)
export const ShopCarSelected = (params) => request('/core/userCart/changeSelected',params)
export const attrValuePrice = (params) => request('/core/cat/attrValuePrice',params,'get')
export const shopDetail = (params) => request('/core/cat/itemDetail',params,'get')
export const pingjiaapi = (params) => request('/core/cat/itemReviews',params,'get')
export const shangchuankanchafangan = (params) => request('/core/userOrder/uploadInspectContract',params)
export const kanchafangan = (params) => request('/core/userOrder/inspectDetail',params,'get')
export const orderDetail = (params) => request('/core/userOrder/detail',params,'get')
export const createOrder = (params) => request('/core/userCart/createOrder',params)
export const reviewsOrder = (params) => request('/core/userOrder/reviews',params)
export const createPay = (params) => request('/core/userCart/payOrder',params)
export const refund = (params) => request('/core/userOrder/addTicket',params)
export const readOrderNotice = (params) => request('/core/userOrder/readOrderNotice',params)
export const editUser = (params) => request('/system/user/updateByCustomer',params)
export const setphone = (params) => request('/auth/requestPhoneCode',params)
export const bdphone = (params) => request('/system/user/bindPhone',params)
export const recharge = (params) => request('/core/userOwner/account/recharge',params)
export const vipfun = () => request('/core/userOwner/memberCardList',{},'get')
export const MyFeedback = (params) => request('/core/userOwner/ticket/list',params,'get')
export const feedback = (params) => request('/core/userOwner/ticket/add',params)
export const coupon = (params) => request('/core/userOwner/coupon/list',params,'get')
export const address = (params) => request('/core/userOwner/address/list',params,'get')
export const deletaddress = (params) => request('/core/userOwner/address/remove',params)
export const city = () => request('/core/systemCity/citySelector',{},'get')
export const communityList = (params) => request('/core/systemCity/communityList',params,'get')
export const addressEdit = (params) => request('/core/userOwner/address/update',params)
export const addressAdd = (params) => request('/core/userOwner/address/add',params)
export const addressDetail = (params) => request('/core/userOwner/address/detail',params,'get')
export const dict = (type) => request(`/system/dict/data/type/${type}`,{},'get')
export const searchClass = (params) => request('/core/cat/search',params,'get')


//获取注册手机号验证码
export const rigisteryzmAPi = (params) => request('/auth/registerPhoneCodeFromEnt', params)
//手机号注册
export const rigisterAPi = (params) => request('/auth/registerByPhoneFromEnt', params)
//登录
export const loginAPi = (params) => request('/auth/login', params)
//服务订单列表
export const contentlistAPi = (params) => request('/core/workerRequest/list', params,'get')
//订单服务详情
export const contentdetailAPi = (params) => request('/core/workerRequest/detail', params,'get')
//勘察师傅接单
export const shifujiedanAPi = (params) => request('/core/workerRequest/rev', params)

export const upImg = (data,type) => {
	return new Promise((resolve, reject) => {
		uni.uploadFile({
			url: `${siteinfo.siteinfo.baseurl}/file/upload`,
			filePath: data.file,
			name: 'file',
			header: {
				Authorization: uni.getStorageSync('access_token'),
			},
			success:(res)=> {
				res.data = JSON.parse(res.data)
				if(res.data.code === 200){
					resolve(res.data)
				}else{
					reject(res.data)
					uni.showToast({
						title:res.data.msg,
						icon:'none'
					})
				}
			},
			fail: (err) => {
				reject(err)
			}
		});
	})
}


export default{
 login,getUser,getMainClass,services,recommend,searchswiper,gwcnums,orderNoticeNum,
 classDetail,classList,cancalOrder,confirmOrder,closeOrder,ticketList,getOrderList,
 balance,orderpingjia,ShopCar,addShopCar,gwcaradd,ShopCarDelete,ShopCarSelected,attrValuePrice,
 pingjiaapi,shopDetail,refund,createPay,reviewsOrder,createOrder,kanchafangan,shangchuankanchafangan,
 readOrderNotice,orderDetail,editUser,upImg,setphone,bdphone,recharge,vipfun,feedback,MyFeedback,coupon,
 deletaddress,address,city,communityList,addressEdit,addressAdd,addressDetail,dict,searchClass,register,
 getcode,rigisteryzmAPi,rigisterAPi,loginAPi,contentlistAPi,contentdetailAPi,shifujiedanAPi
 
}